<template>
  <div class="home-banner">
    <Slider :data="sliderData" autoplay></Slider>
  </div>
</template>

<script>
import { findBanner } from '@/api/home.js'
import { ref, onMounted } from 'vue'

// 封装函数 复用逻辑
const useSlider = () => {
  const sliderData = ref([])
  const getList = async () => {
    const data = await findBanner()
    console.log('返回数据', data)
    sliderData.value = data.result
  }
  onMounted(() => {
    getList()
  })
  return { sliderData }
}
export default {
  name: 'HomeBanner',
  setup () {
    const { sliderData } = useSlider()
    return { sliderData }
  }
}
</script>

<style scoped lang='less'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
}
</style>
